<link type="text/css" rel="stylesheet" href="__PUBLIC__/css/validator.css"/>
<script type="text/javascript" src="__PUBLIC__/js/checkuser.js"></script>
<style>
    .close{font-size:34px;font-weight:400;color:#fff;}
    .close:hover{color:#fff;}
</style>
<div class="modal-header" style="border:none;">
    <b style="font-size:16px;">编辑发票</b>
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
</div>
<div class="modal-body col-sm-12">
    <form class="form-horizontal m-t" id="ad_Form" action="#" method="post" role="form">
        <input type="hidden" name="invoice_id" value="{$invoice_info['id']}" />
        <div class="form-group ">
            <div class="col-sm-1"></div>
            <label class="control-label col-sm-2" for="invoice_header" ><span style="color:#FF0011;">*</span>开票抬头：</label>
            <div class="col-sm-6">
                <input type="text" id="invoice_header" name="invoice_header" value="{$invoice_info['invoice_header']}" rel="require" rell="内容" class="form-control checkit" onblur="checkform(this);" />
            </div>
            <div class="col-sm-3 error_msg" id="invoice_headerTip"></div>
        </div>
        <div class="form-group ">
            <div class="col-sm-1"></div>
            <label class="control-label col-sm-2" for="taxes_num" ><span style="color:#FF0011;">*</span>纳税识别号：</label>
            <div class="col-sm-6">
                <input type="text" id="taxes_num" name="taxes_num" value="{$invoice_info['taxes_num']}" rel="require" rell="内容" class="form-control checkit" onblur="checkform(this);" />
            </div>
            <div class="col-sm-3 error_msg" id="taxes_numTip"></div>
        </div>
        <div class="form-group ">
            <div class="col-sm-1"></div>
            <label class="control-label col-sm-2" for="opening_bank" ><span style="color:#FF0011;">*</span>开户行：</label>
            <div class="col-sm-6">
                <input type="text" id="opening_bank" name="opening_bank" value="{$invoice_info['opening_bank']}" rel="require" rell="内容" class="form-control checkit" onblur="checkform(this);" />
            </div>
            <div class="col-sm-3 error_msg" id="opening_bankTip"></div>
        </div>
        <div class="form-group ">
            <div class="col-sm-1"></div>
            <label class="control-label col-sm-2" for="account_number" ><span style="color:#FF0011;">*</span>开户账号：</label>
            <div class="col-sm-6">
                <input type="text" id="account_number" name="account_number" value="{$invoice_info['account_number']}" rel="require" rell="内容" class="form-control checkit" onblur="checkform(this);" />
            </div>
            <div class="col-sm-3 error_msg" id="account_numberTip"></div>
        </div>
        <div class="form-group ">
            <div class="col-sm-1"></div>
            <label class="control-label col-sm-2" for="billing_address" ><span style="color:#FF0011;">*</span>开票地址：</label>
            <div class="col-sm-6">
                <input type="text" id="billing_address" name="billing_address" value="{$invoice_info['billing_address']}" rel="require" rell="内容" class="form-control checkit" onblur="checkform(this);" />
            </div>
            <div class="col-sm-3 error_msg" id="billing_addressTip"></div>
        </div>
        <div class="form-group ">
            <div class="col-sm-1"></div>
            <label class="control-label col-sm-2" for="telephone" ><span style="color:#FF0011;">*</span>电话：</label>
            <div class="col-sm-6">
                <input type="text" id="telephone" name="telephone" value="{$invoice_info['telephone']}" rel="require" rell="内容" class="form-control checkit" onblur="checkform(this);" />
            </div>
            <div class="col-sm-3 error_msg" id="telephoneTip"></div>
        </div>
    </form>
</div>
<div class="modal-footer">
    <div class="form-actions">
        <button class="btn btn-primary" id="adbtn" type="button">
            保存
        </button>
        <a class="btn btn-sm btn-white" data-dismiss="modal" href="javascript:;">取消</a>
    </div>
</div>

<script>
$("#adbtn").click(function(){
    if(input_msg && before_submit()){
        $.ajax({
            type: "POST",
            url: "{:U('invoice/editData')}",
            data:$("#ad_Form").serialize(),
            async: true,
            success: function(data) {
                if(data.status == 1){
                    $('#addInvoice').modal('hide');
                    location.reload();
                }else{
                    swal({
                        title: "添加失败!",
                        text: data.info,
                        type: "error"
                    });
                    return false;
                }
            }
        });
    }else{
        var item_id = [];
        $('.checkit').each(function(k,v){
            checkform(v);
            item_id.push($(v).attr('id'));
        });
        $.each(item_id,function(k,v){
            if($('#'+v+'Tip').html() == ''){
                item_id.splice(k,1);
            }
        });
        $('#'+item_id[0]).focus();
        return false;
    }
});
</script>